package com.xgsm.fastdfsdemo.Controller;

import com.xgsm.fastdfsdemo.Bean.CusAccessObjectUtil;
import com.xgsm.fastdfsdemo.Service.BigDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClaseName: BigDataCollectionController$
 * @Description:数据收集-用于SQL优化
 * @Author: wuhs
 * @Date: 2023/8/21$ 14:44$
 */
@RestController
@RequestMapping("/bigdata")
@Api(value = "数据收集", description = "fastDFs分布式文件存储 -- 文件上传下载")
@CrossOrigin//跨域的意思
public class BigDataCollectionController {
    @Autowired
    private BigDataService bigDataService;
    private CusAccessObjectUtil cusAccessObjectUtil;

    @ApiOperation("添加")
    @Async("asyncServiceExecutor")
    @RequestMapping(value = "/insert", method = RequestMethod.GET)
    public int insetrBigData(String message, String type, HttpServletRequest request) {
        cusAccessObjectUtil = new CusAccessObjectUtil();
        String ipAddress = CusAccessObjectUtil.getClientIpAddr(request);
        System.out.println("message==>" + message);
        System.out.println("type==>" + type);
        System.out.println("ipAddress==>"+ipAddress);
        return bigDataService.insertData(message, type,ipAddress);
    }
}
